﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RoboTrocity {
	class AIModule {
		WaypointCollection waypointGroup;
		Waypoint destination;
		/// <summary>
		/// The Enemy that this AIModule is attached to.
		/// </summary>
		Enemy attachedEnemy; 

		public AIModule(Enemy _attachedEnemy) {
			attachedEnemy = _attachedEnemy;
		}

		public void Update() {
			/*if (destination == null) {
				destination = waypointGroup.getNextWaypoint();
			}
			if (Math.Abs(attachedEnemy.Position.X - destination.Position.X) < 10) {
				destination = waypointGroup.getNextWaypoint(destination);
			}
			if (destination.Position.X > attachedEnemy.Position.X) {
				attachedEnemy.moveRight();
			} else {
				attachedEnemy.moveLeft();
			}*/
			if (attachedEnemy.FacingLeft) {
				attachedEnemy.moveLeft();
			} else {
				attachedEnemy.moveRight();
			}
		}

		public void CollideWithTerrain() {
			attachedEnemy.setVelocityX(0);
			attachedEnemy.switchDirections();
		}

		public WaypointCollection WPCollection {
			get { return waypointGroup; }
			set { waypointGroup = value; }
		}

		/// <summary>
		/// Returns the destination Waypoint.
		/// </summary>
		public Waypoint Destination {
			get { return destination; }
			set { destination = value; }
		}

	}
}
